package cn.hd01.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import cn.hd01.repository.entity.IntegrationRuleBook;

@Repository
public interface IntegrationRuleBookRepository extends JpaRepository<IntegrationRuleBook, Integer> {
	
	Page<IntegrationRuleBook> findAll(Specification<IntegrationRuleBook> spec, Pageable pageable);
	
	@Query("select count(1) from IntegrationRuleBook where customer_id = ?1 and rule_code = ?2 and DATE_FORMAT(create_time,'%y%m%d') = DATE_FORMAT(NOW(),'%y%m%d')")
	int countTodayRule(Integer id, String ruleCode);
}
